package com.ruanyun.modular.admin.controller;

import com.ruanyun.base.pojo.page.LayuiPageInfo;
import com.ruanyun.modular.admin.entity.TExhaustOutlet;
import com.ruanyun.modular.admin.model.params.PollutantsParam;
import com.ruanyun.modular.admin.model.params.TExhaustOutletParam;
import com.ruanyun.modular.admin.model.result.PollutantsResult;
import com.ruanyun.modular.admin.service.TExhaustOutletService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 废气排放口控制器
 *
 * @author zs
 * @Date 2021-04-17 15:39:55
 */
@Controller
@RequestMapping("/tExhaustOutlet")
public class TExhaustOutletController extends BaseController {

    private String PREFIX = "/tExhaustOutlet";

    @Autowired
    private TExhaustOutletService tExhaustOutletService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/tExhaustOutlet.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/tExhaustOutlet_add.html";
    }


    /**
     * 新增废气排放口
     *
     * @author zs
     * @Date 2021-04-27
     */
    @RequestMapping("/addPollutants")
    public String addPollutants() {
        return PREFIX + "/addPollutants.html";
    }




    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/tExhaustOutlet_edit.html";
    }



    /**
     * 编辑废气污染物页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/editP")
    public String editP() {
        return PREFIX + "/tExhaustOutlet_editP.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(TExhaustOutletParam tExhaustOutletParam) {
        return this.tExhaustOutletService.add(tExhaustOutletParam);
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(TExhaustOutletParam tExhaustOutletParam) {
        return this.tExhaustOutletService.update(tExhaustOutletParam);
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(TExhaustOutletParam tExhaustOutletParam) {
        return this.tExhaustOutletService.updateDelFlagById((long)tExhaustOutletParam.getId());
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(TExhaustOutletParam tExhaustOutletParam) {
        TExhaustOutlet detail = this.tExhaustOutletService.getById(tExhaustOutletParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2021-04-17
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(TExhaustOutletParam tExhaustOutletParam) {
        return this.tExhaustOutletService.findPageBySpec(tExhaustOutletParam);
    }

    /**
     * 启用
     *
     * @author zs
     * @Date 2021-04-17
     */
    @ResponseBody
    @RequestMapping("/enable")
    public ResponseData enable(@RequestParam Long id) {
        return this.tExhaustOutletService.enableById(id);
    }

    /**
     * 禁用
     *
     * @author zs
     * @Date 2021-04-17
     */
    @ResponseBody
    @RequestMapping("/disable")
    public ResponseData disable(@RequestParam Long id) {
        return this.tExhaustOutletService.disableById(id);
    }



    /**
     * 新增污染物种类
     *
     * @author zs
     * @Date 2021-04-27
     */
    @RequestMapping("/addPollutantss")
    @ResponseBody
    public ResponseData addPollutantss(PollutantsParam pollutantsParam) {
        return this.tExhaustOutletService.addPollutants(pollutantsParam);
    }


    /**
     * 查询污染物种类列表
     *
     * @author zs
     * @Date 2021-04-17
     */
    @ResponseBody
    @RequestMapping("/pollutantsList")
    public LayuiPageInfo pollutantsList(PollutantsParam PollutantsParam) {
        return this.tExhaustOutletService.pollutantsList(PollutantsParam);
    }


    /**
     * 编辑污染物页面
     *
     * @author zs
     * @Date 2021-04-17
     */
    @RequestMapping("/editPollutants")
    public String editPollutants() {
        return PREFIX + "/editPollutants.html";
    }

    /*污染物详情*/
    @RequestMapping("/pollutantsDetail")
    @ResponseBody
    public ResponseData pollutantsDetail(PollutantsParam pollutantsParam) {
        PollutantsResult detail = this.tExhaustOutletService.pollutantsDetail(pollutantsParam.getId());
        return ResponseData.success(detail);
    }

    /*修改污染物*/

    @RequestMapping("/updatePollutants")
    @ResponseBody
    public ResponseData editItem(PollutantsParam pollutantsParam) {
        return this.tExhaustOutletService.updatePollutants(pollutantsParam);
    }


    /*删除污染物*/
    @RequestMapping("/deletePollutants")
    @ResponseBody
    public ResponseData deletePollutants(PollutantsParam pollutantsParam) {
        return this.tExhaustOutletService.delP(pollutantsParam.getId());
    }


}


